package com.xnyzc.lhy.order.controller.capi.evaluation;

import com.xnyzc.lhy.common.component.didi.DiDiUrlConstant;
import com.xnyzc.lhy.common.entity.DiDiRv;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.DiDiException;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EDiDiErrorCode;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.common.util.sign.AttestationTool;
import com.xnyzc.lhy.order.entity.param.comment.EvaluationParam;
import com.xnyzc.lhy.order.service.evaluation.EvaluationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 评价相关
 * </p>
 *
 * @author wangshuo
 * @since 2019-09-25
 */
@RestController
@RequestMapping("oa/capi/evaluation")
public class EvaluationController {

    @Autowired
    private EvaluationService evaluationService;

    /**
     * 乘客评价司机
     *
     * @param evaluationParam
     * @return
     */
    @ApiOperation(value = "乘客评价司机", notes = "乘客评价司机")
    @PostMapping(value = "/addEvaluate")
    @ResponseBody
    public Rv addEvaluate(@RequestBody EvaluationParam evaluationParam) {

        Long userId = TokenUtil.getTokenUserId();
        if (CheckUtil.objIsEmpty(userId)){
            throw PangException.create(EErrorCode.tokenExpire);
        }
        String tag = TokenUtil.getTag();
        if (StringUtils.isEmpty(tag)){
            throw PangException.create(EErrorCode.missingAuthArgs);
        }
        evaluationParam.setTag(tag);
        evaluationParam.setUserId(userId);
        return evaluationService.addEvaluate(evaluationParam);
    }

}
